﻿// -----------------------------------------------------------------------
// <copyright file="Overlay.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

using System.Globalization;

namespace Cubezicles
{
    using System;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class Overlay : DrawableGameComponent
    {
        private Game1 game1 { get { return (Game1)Game; } }

        public string Objective { get; set; }

        public Overlay(Game1 game) : base(game) 
        {
            this.DrawOrder = (int)Game1.DisplayOrder.UI;
            Objective = "Objective: Be Awesome~ (Earn {0})";
        }

        public override void Draw(GameTime gameTime)
        {
            game1.SpriteBatch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend);

            drawTimeBar();
            drawMoneyBar();

            //Draw Objective
            var where = new Vector2(210, GraphicsDevice.Viewport.Height - 25);
            var what = string.Format(Objective, MoneyManager.GoalFunds);
            game1.SpriteBatch.DrawString(game1.Fonts["status"], what, where, Color.White);

            
            game1.SpriteBatch.End();

            base.Draw(gameTime);
        }


        /// <summary>
        /// Draw the timer bar at the top of the screen
        /// </summary>
        /// <param name="gameTime">Time elapsed since last frame/beginning</param>
        private void drawTimeBar()
        {
            string timeDisplay = game1.time.display();
            game1.SpriteBatch.DrawString(game1.Fonts["status"], timeDisplay, 
                new Vector2(10, 5), Color.White);
        }

        // from lizz: 
        private void drawMoneyBar()
        {
            // still need to add in $$ sign and stuff
            // and fix position

            String moneyText = "$" + game1.MoneyManager.CurrentFunds.ToString(CultureInfo.CurrentCulture);
            Color textcolor = game1.MoneyManager.CurrentFunds < 0 ? Color.Red : Color.White;
            game1.SpriteBatch.DrawString(game1.Fonts["status"], moneyText,
                new Vector2(GraphicsDevice.Viewport.Width - game1.Fonts["status"].MeasureString(moneyText).X - 10, 5), textcolor);
        }
    }
}
